<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.16"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>DesignPattern: C:/96_project/DesignPattern/01_Singleton/DESIGNPATTERN_Singleton.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="DesignPattern.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">DesignPattern
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.16 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_df134bdc6cd8b6ac6a91f8ed4096bc7a.html">01_Singleton</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">DESIGNPATTERN_Singleton.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___singleton_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160; </div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="stdafx_8h.html">stdafx.h</a>&quot;</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160; </div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#ifndef CXX_DESIGNPATTERN_SINGLETON_H</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_d_e_s_i_g_n_p_a_t_t_e_r_n___singleton_8h.html">DESIGNPATTERN_Singleton.h</a>&quot;</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160; </div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<a class="code" href="class_singleton.html">Singleton</a>* <a class="code" href="class_singleton.html#a4b6cbfb98cff93721671b349098102bc">Singleton::m_pInstance</a> = NULL;</div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160; </div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160; </div>
<div class="line"><a name="l00022"></a><span class="lineno"><a class="line" href="class_singleton.html#a0e21dfc9afab45b0a6a70f6665ce5819">   22</a></span>&#160;<a class="code" href="class_singleton.html#a0e21dfc9afab45b0a6a70f6665ce5819">Singleton::Singleton</a>()</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;{</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;    <a class="code" href="_my_self_def_8h.html#a0be11ce2e33906806ac4e521781809c0">DEBUG_PRINTF</a>(<span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;}</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160; </div>
<div class="line"><a name="l00033"></a><span class="lineno"><a class="line" href="class_singleton.html#a543d81b5f1458e51fe1a56082b6afccc">   33</a></span>&#160;<a class="code" href="class_singleton.html#a543d81b5f1458e51fe1a56082b6afccc">Singleton::~Singleton</a>()</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;{</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;    <a class="code" href="_my_self_def_8h.html#a0be11ce2e33906806ac4e521781809c0">DEBUG_PRINTF</a>(<span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;}</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160; </div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;<a class="code" href="class_singleton.html">Singleton</a>* </div>
<div class="line"><a name="l00046"></a><span class="lineno"><a class="line" href="class_singleton.html#a01073bb7481d82d783309be8ba3f51ba">   46</a></span>&#160;<a class="code" href="class_singleton.html#a01073bb7481d82d783309be8ba3f51ba">Singleton::Instance</a>()</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;{</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    <a class="code" href="_my_self_def_8h.html#a0be11ce2e33906806ac4e521781809c0">DEBUG_PRINTF</a>(<span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;    <span class="keywordflow">if</span> (NULL == <a class="code" href="class_singleton.html#a4b6cbfb98cff93721671b349098102bc">m_pInstance</a>) {</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;        <a class="code" href="class_singleton.html#a4b6cbfb98cff93721671b349098102bc">m_pInstance</a> = <span class="keyword">new</span> <a class="code" href="class_singleton.html#a0e21dfc9afab45b0a6a70f6665ce5819">Singleton</a>;</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    }</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_singleton.html#a4b6cbfb98cff93721671b349098102bc">m_pInstance</a>;</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;}</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160; </div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160; </div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;<a class="code" href="_my_self_def_8h.html#a7927e087749615dae3114cc27b91c86d">VOID</a> </div>
<div class="line"><a name="l00064"></a><span class="lineno"><a class="line" href="class_singleton.html#a162d66724c6eac1ab293989c5c72f8df">   64</a></span>&#160;<a class="code" href="class_singleton.html#a162d66724c6eac1ab293989c5c72f8df">Singleton::Destroy</a>()</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;{</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;    <a class="code" href="_my_self_def_8h.html#a0be11ce2e33906806ac4e521781809c0">DEBUG_PRINTF</a>(<span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;    <span class="keywordflow">if</span> (NULL != <a class="code" href="class_singleton.html#a4b6cbfb98cff93721671b349098102bc">m_pInstance</a>) {</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;        <span class="keyword">delete</span> <a class="code" href="class_singleton.html#a4b6cbfb98cff93721671b349098102bc">m_pInstance</a>;</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;        <a class="code" href="class_singleton.html#a4b6cbfb98cff93721671b349098102bc">m_pInstance</a> = NULL;</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;    }</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;}</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160; </div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;<span class="comment">/* EOF */</span></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclass_singleton_html_a543d81b5f1458e51fe1a56082b6afccc"><div class="ttname"><a href="class_singleton.html#a543d81b5f1458e51fe1a56082b6afccc">Singleton::~Singleton</a></div><div class="ttdeci">~Singleton()</div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___singleton_8cpp_source.html#l00033">DESIGNPATTERN_Singleton.cpp:33</a></div></div>
<div class="ttc" id="aclass_singleton_html"><div class="ttname"><a href="class_singleton.html">Singleton</a></div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___singleton_8h_source.html#l00011">DESIGNPATTERN_Singleton.h:11</a></div></div>
<div class="ttc" id="a_my_self_def_8h_html_a7927e087749615dae3114cc27b91c86d"><div class="ttname"><a href="_my_self_def_8h.html#a7927e087749615dae3114cc27b91c86d">VOID</a></div><div class="ttdeci">void VOID</div><div class="ttdef"><b>Definition:</b> <a href="_my_self_def_8h_source.html#l00011">MySelfDef.h:11</a></div></div>
<div class="ttc" id="astdafx_8h_html"><div class="ttname"><a href="stdafx_8h.html">stdafx.h</a></div></div>
<div class="ttc" id="aclass_singleton_html_a0e21dfc9afab45b0a6a70f6665ce5819"><div class="ttname"><a href="class_singleton.html#a0e21dfc9afab45b0a6a70f6665ce5819">Singleton::Singleton</a></div><div class="ttdeci">Singleton()</div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___singleton_8cpp_source.html#l00022">DESIGNPATTERN_Singleton.cpp:22</a></div></div>
<div class="ttc" id="a_d_e_s_i_g_n_p_a_t_t_e_r_n___singleton_8h_html"><div class="ttname"><a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___singleton_8h.html">DESIGNPATTERN_Singleton.h</a></div><div class="ttdoc">To ensure that a class has only one instance.</div></div>
<div class="ttc" id="a_my_self_def_8h_html_a0be11ce2e33906806ac4e521781809c0"><div class="ttname"><a href="_my_self_def_8h.html#a0be11ce2e33906806ac4e521781809c0">DEBUG_PRINTF</a></div><div class="ttdeci">#define DEBUG_PRINTF(fmt, args...)</div><div class="ttdef"><b>Definition:</b> <a href="_my_self_def_8h_source.html#l00025">MySelfDef.h:25</a></div></div>
<div class="ttc" id="aclass_singleton_html_a01073bb7481d82d783309be8ba3f51ba"><div class="ttname"><a href="class_singleton.html#a01073bb7481d82d783309be8ba3f51ba">Singleton::Instance</a></div><div class="ttdeci">static Singleton * Instance()</div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___singleton_8cpp_source.html#l00046">DESIGNPATTERN_Singleton.cpp:46</a></div></div>
<div class="ttc" id="aclass_singleton_html_a4b6cbfb98cff93721671b349098102bc"><div class="ttname"><a href="class_singleton.html#a4b6cbfb98cff93721671b349098102bc">Singleton::m_pInstance</a></div><div class="ttdeci">static Singleton * m_pInstance</div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___singleton_8h_source.html#l00068">DESIGNPATTERN_Singleton.h:68</a></div></div>
<div class="ttc" id="aclass_singleton_html_a162d66724c6eac1ab293989c5c72f8df"><div class="ttname"><a href="class_singleton.html#a162d66724c6eac1ab293989c5c72f8df">Singleton::Destroy</a></div><div class="ttdeci">static VOID Destroy()</div><div class="ttdef"><b>Definition:</b> <a href="_d_e_s_i_g_n_p_a_t_t_e_r_n___singleton_8cpp_source.html#l00064">DESIGNPATTERN_Singleton.cpp:64</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.16
</small></address>
</body>
</html>
